package com.computergames.server.server.session;

import com.computergames.server.util.RedisUtil;
import io.netty.channel.Channel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

@Repository
public class SessionDaoImpl implements SessionDao{
    @Autowired
    RedisUtil redisUtil;

    @Override
    public void addSession(Channel channel, String username) {
        redisUtil.set(username, channel);
    }

    @Override
    public void removeSession(String username) {
        redisUtil.del(username);
    }

    @Override
    public Channel getChannel(String username) {
        return (Channel) redisUtil.get(username);
    }
}
